package com.sc.nft.service.impl;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sc.nft.dao.MallActivitySpecsDao;
import com.sc.nft.dto.MallActivitySpecsGetSendCodeDTO;
import com.sc.nft.entity.MallActivitySpecs;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.service.MallActivitySpecsService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;

/**
 * IP商城活动规格表服务接口实现
 *
 * @author zxy
 * @description IP商城
 * @since 2023-05-10 16:59:01
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class MallActivitySpecsServiceImpl implements MallActivitySpecsService {
    private final MallActivitySpecsDao mallActivitySpecsDao;

    @Override
    public MallActivitySpecs getById(Long specsId) {
        return mallActivitySpecsDao.getById(specsId);
    }

    @Override
    public List<MallActivitySpecs> getByActivityId(Long activityId) {
        return mallActivitySpecsDao.getByActivityId(activityId);
    }

    @Override
    public Boolean frozenStockByIdAndCount(Long id, Integer count) {
        return mallActivitySpecsDao.frozenStockByIdAndCount(id, count);
    }

    @Override
    public Boolean subFrozenCount(Long id, Integer count) {
        return mallActivitySpecsDao.subFrozenCount(id, count);
    }

    @Override
    public Boolean frozenConsumeStockByIdAndCount(Long id, Integer count) {
        return mallActivitySpecsDao.frozenConsumeStockByIdAndCount(id, count);
    }

    @Override
    public Boolean updateUsableStockCountById(Long id, Integer addCount) {
        return mallActivitySpecsDao.updateUsableStockCountById(id, addCount);
    }

    @Override
    public void updateMallActivitySalesPriceById(Long id, BigDecimal salesPrice, BigDecimal profit) {
        mallActivitySpecsDao.updateMallActivitySalesPriceById(id, salesPrice,profit);
    }

    /**
     * 根据id查询
     *
     * @param activitySpecsId
     * @return
     */
    @Override
    public MallActivitySpecs getByIdWithoutDeleted(Long activitySpecsId) {
        return mallActivitySpecsDao.getByIdWithoutDeleted(activitySpecsId);
    }


    /**
     * 根据规格id获取发货编码
     *
     * @param activitySpecsIdList
     * @return
     */
    @Override
    public List<MallActivitySpecsGetSendCodeDTO> getSendCodeByActivitySpecsIdList(List<Long> activitySpecsIdList) {
        return mallActivitySpecsDao.getSendCodeByActivitySpecsIdList(activitySpecsIdList);
    }
}